<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/">
  <xi:include href="sqa_nav.html" />

  <head>
    <title>Test Exec</title>
	<py:if test="stepError">
	 <script>
	 	$(document).ready(function() {
			case_id = "${stepError}";
			user = "${req.authname}";
			reg = $("input[name=test_reg_num]").val()
			//alert("Case id = "+ case_id);
			/*
			 * Change the color of the row containing the failed test step
			 */
			
			$('#row_'+case_id).css("background-color","#FF0000");
			// Disable all inputs
			$(':input').attr('disabled', true);
			$.get("ajax", {ajax_request: "Event", step_result:"{Trac Ticket} Defect [ TestCaseID " + case_id +" ] Reviewed By "+user , Step: 0, TestReg: reg }  );
		});
	 </script>
	</py:if>
  </head>

  <body>
  	<h2>Test Execution</h2>
	<!-- determine which type of for to render
	Registration 
	or
	Test execution
	-->
	
	<!-- ! register Test -->
	<py:choose test="">
		<py:when test="complete">
			<h3>Test Complete, View Test Log for More Details</h3>
		</py:when>	
		<py:when test="run">
		<!-- ! Execute Test Steps -->
		<form id="TestForm" method="post" py:with="revoke_perm = 'PERMISSION_REVOKE' in perm" action="">
		<table>
			<tr><td>Steps Remaining</td><td id="step_remain"></td></tr>
			<!-- <tr><td>Debug</td><td id="step_debug"></td></tr> -->
		</table>
		<input type="hidden" name="test_reg_num" value="${reg}" />
		<input type="hidden" name="_user" value="${req.authname}" />
		<py:if test="stepError">
		<input type="hidden" name="_defect" value="_read" />
		</py:if>
		<input type="hidden" name="test_case_report" value="${href.sqa('report', reg_id=reg )}" />
		<input type="hidden" name="ticket_url" value="${href.sqa('ticket_form', reg_id=reg )}" />
		<input type="hidden" name="sqa_control" value="End Test" />

	  <xi:include href="testItem.html" />
	  
	  <input type="button" id="_endtest" value="End Test" />
	  </form>

			 
			
			<!-- ! END Execute Test Steps -->
		</py:when>
	<py:otherwise>
	<!-- Show the form -->	
    <form id="regform" method="post" py:with="revoke_perm = 'PERMISSION_REVOKE' in perm" action="">
	  <input type="hidden" name="plan_id" value="${plan.id}" />	
	  <input id="te_browser" type="hidden" name="browser" value="No Set" /> 
	  <input id="te_browserver" type="hidden"  name="browser_ver" value="No Set" /> 
	  <input type="hidden" name="user_agent"  value="No Set" /> 
	  <input type="hidden"  name="client_plfrm" value="No Set" /> 
	  <input type="hidden" name="tester_name" value="${user}" />
	  	<div style="width:400px">
	  	<fieldset>
        <legend>Test Registration (${user}):</legend>	
		 <table>
		 	<tr>
		 		<td>
		 			<label>Milestone:</label>
		 		</td><td>
		 			${plan.milestone}
		 		</td>
		 	</tr><tr>
		 		<td>
		 			<label>Test Name:</label>
		 		</td>
				<td>
		 			${plan.plan_name}
		 		</td>
		 	</tr><tr>
		 		<td>
		 			<label>Test Steps:</label>
		 		</td><td>
		 			<input id="te_step_cnt" type="text" name="step_cnt" size="3" disabled="true" value=" ${steps.count}" />
		 		</td>
		 	</tr><tr>
		 		<td>
		 			<label>Test Type:</label>
		 		</td><td>
		 			<input id="gp_subject" type="text" name="test_type" size="30" disabled="true" value=" ${plan.test_type}" />
		 		</td>
		 	</tr><tr>
		 		<td>
		 			<label>Tester Name:</label>
		 		</td><td>
					<input id="te_tester_name" type="text" name="__tester_name" disabled="true" value="${user}" />
		 		</td>
		 	</tr> 
			</table>
			<table>
			<tr>
	 			<td>
					<div py:for="item in ticket" id="ticket_field" >
						<div py:choose="item.type">
							<span py:when="'text'">
								<label for="${item.name}">${item.label}:</label><input type="text" id="${item.name}" name="${item.name}"   />
							</span>
							<span py:when="'textarea'">
								<fieldset>
								<legend>${item.label}:</legend>
								<textarea id="${item.name}" cols="85" rows="10" class="wikitext trac-resizable" name="${item.name}" ></textarea>
								</fieldset>
							</span>
							<span py:when="'radio'">
								<fieldset>
									<legend>${item.label}</legend>
									<py:for each="option in item.options">
										<label for="option">${option}:</label><input type="radio" id="${option}" name="${item.name}" value="${option}" />
									</py:for>
								</fieldset>
							</span>
							<span py:when="'select'">
								
								<label for="${item.name}">${item.label}:</label> <select id="${item.name}" name="${item.name}" >
									<py:for each="option in item.options">
										<option value="${option}">${option}</option>
									</py:for>
								</select>
							</span>
						</div>
					</div>
	 			</td>	
			</tr>
		 </table>
		 <table>
		 	<tr>
				<td>
					<fieldset>
					 <legend>Testing Conditions</legend>
					  <textarea cols="85" rows="10" class="wikitext" name="_conditions" ></textarea>
					</fieldset>
				</td>
			</tr>
			<tr>
				<td>
					<fieldset>
					 <legend>Comments</legend>
					  <textarea cols="85" rows="10" class="wikitext" name="_comments" ></textarea>
					</fieldset>
				</td>
			</tr>
		 </table>
		 </fieldset>
		 </div>
      <div class="buttons">
      	
        <!-- !Default Options
		
		 -->
		<input type="submit" name="sqa_control" value="${_('Register Test')}" />
		<!--
		<a href="${href.sqa('case', plan.id, 'edit')}">Edit Test Case</a>	
		<a href="${href.sqa('case', plan.id, 'edit')}">Edit Test Case</a>	
      	-->
	  </div>
    </form>
	</py:otherwise>
	</py:choose>

	<!-- !
	
    <form id="regform" method="post" py:with="revoke_perm = 'PERMISSION_REVOKE' in perm" action="">
      
	  <input type="hidden" name="table_order" value="NOCHANGE" />
	  <input type="hidden" name="plan_id" value="${plan.id}" />	
	  	 
		  <ul>
		  	<li>Milestone: ${plan.milestone}</li>
			<li>Description: ${plan.description}</li>
			<li>Test Type: ${plan.test_type}</li>
		  </ul>
		<table class="listing" id="tc_steplist-1">
      	
        <thead>
          <tr>
          	<py:if test="run">
			<th >Remove</th>
			</py:if>
			<th>Order</th><th>Name</th><th>Test Procedure</th><th>Expected Result</th>
		  </tr>
        </thead>
        
		
        
		<tr py:for="step in case" id="${step.case_id}">
				
				<py:if test="edit">
				<td ><input type="checkbox" name="test_case_step_id" value="${step.case_id}"/></td>
				</py:if>			
        		<td>${step.test_order}</td>
		
				<td>${step.item_name}</td>
				
				<td id="wikipage">${step.test_procedure}</td>
				
				<td>${step.expected_result}</td>
				
        </tr>
        
      </table>
      <div class="buttons">
      	
        
		<py:choose test="edit">
			<py:when test="edit">
		 
				<a href="${href.sqa('case', plan.id)}"> Exit Edit Mode </a>
				<br/>
				<input type="submit" name="sqa_control" value="${_('Reorder Steps')}" />
				
		
					<input type="submit" name="sqa_control" value="${_('Disable Step')}" />
		
						<input type="submit" name="sqa_control" value="${_('Remove Step')}" />
					
			</py:when>
			<py:otherwise>
				<a href="${href.sqa('exec', plan.id)}">Execute Test Case</a> 
				||
				<a href="${href.sqa('case', plan.id, 'edit')}">Edit Test Case</a>	
			</py:otherwise>
    	</py:choose>	
      </div>
    </form>
  		-->

  
  </body>
</html>
